package com.xiongjie.ClusterLimit.service;

import com.xiongjie.ClusterLimit.Interface.impl.IClusterLimitImpl;
import com.xiongjie.ClusterLimit.entity.ClusterLimitEntity;
import org.infinispan.Cache;

import java.util.Random;
import java.util.concurrent.TimeUnit;

public class SClusterLimitService extends IClusterLimitImpl {

    final private static String BASE_URL = "http://.../...";
    private final String apiKey;
    final Random random;

    public SClusterLimitService(String apiKey, Cache<String, Object> cache) {
        super(cache);
        this.apiKey = apiKey;
        random = new Random();

        //TODO 其他初始化
    }

    @Override
    protected ClusterLimitEntity getClusterLimitEntity(String name) {
        try {
            TimeUnit.MILLISECONDS.sleep(200);
        } catch (InterruptedException e) {
        }

        //TODO 其他业务调用

        return new ClusterLimitEntity(name.trim(), name + random.nextFloat());
    }

}
